let marbleRaceLevel15_3 = {
	name: 'Game 15 Level 3',
	id: '15_3',
	type: 'elimination',
	eliminated: 1,
	objects: [
		// Portals
		{
			type: 'object',
			shape: 'rect',
			color: '@goal',
			toPortal: 'goal',
			isGoal: true,
			x: 340,
			y: 80,
			width: 520,
			height: 40
		},
		{
			type: 'object',
			shape: 'circle',
			color: '@a',
			portalID: 'a',
			x: 340,
			y: 150,
			radius: 5,
		},

		// Goal portal
		{
			type: 'object',
			shape: 'circle',
			color: '@goal',
			portalID: 'goal',
			x: 700,
			y: 80,
			radius: 5
		},

		// Obstacles

		// Borders
		{
			type: 'object',
			shape: 'rect',
			color: '@tertiary',
			x: 400,
			y: 0,
			width: 800,
			height: 120
		},
		{
			type: 'object',
			shape: 'rect',
			color: '@tertiary',
			x: 400,
			y: 600,
			width: 800,
			height: 120
		},
		{
			type: 'object',
			shape: 'rect',
			color: '@tertiary',
			x: 0,
			y: 300,
			width: 160,
			height: 600
		},
		{
			type: 'object',
			shape: 'rect',
			color: '@tertiary',
			x: 800,
			y: 300,
			width: 160,
			height: 600
		},
		{
			type: 'object',
			shape: 'rect',
			color: '@tertiary',
			x: 640,
			y: 300,
			width: 80,
			height: 600
		},

		// Marbles
		{
			type: 'marbles',
			x: 340,
			y: 300,
			launchTime: 3,
			launchRadius: 75,
			passX: 700,
			passY: 80,
			radius: 8,
			eliminatedRadius: 6,
			velocity: 5
		},
	]
}
{
	let cntI = 3
	for (let i = 0; i <= cntI; ++i) {
		let cntJ = 4 + (i % 2)
		for (let j = 0; j <= cntJ; ++j){
			let x0=340 + (j - cntJ * .5) * 100
			//let p0= (i- cntI * .5) *0.1667
			let p0= (i- cntI * .5) *0.25
			marbleRaceLevel15_3.objects.push({
				type: 'object',
				shape: 'rect',
				color: '@secondary',
				x: x0,
				y: 300,
				width:40,
				height:20,
				onBeforeUpdate:function(object,engine){
					let phase=p0-.2*engine.time
					phase-=Math.floor(phase)
					engine.setPosition(object.body,[x0,520*phase+80])
					//engine.setAngle(object.body,5*Math.sin(5*engine.time))
				},
				onCollide: function (object, marbleID, engine) {
					engine.setVelocity(engine.circleArray[marbleID], [engine.random(-5,5),engine.random(-6,0)])
				},
			})}
	}
}
marbleRaceLevels.push(marbleRaceLevel15_3)